From 02625ba87c4edd15a2c54b6dcdc70a3ad256c93b Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Sat, 17 Dec 2016 09:08:14 -1000 Subject: [PATCH] make sure we use the check profile where possible for lib deps. Fixes #3418 --- src/cargo/ops/cargo_rustc/context.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index f01c0b141..1185fd64a 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -169,9 +169,9 @@ impl<'a, 'cfg> Context<'a, 'cfg> { kind: Kind) -> CargoResult<()> { let rustflags = env_args(self.config, - &self.build_config, - kind, - "RUSTFLAGS")?; + &self.build_config, + kind, + "RUSTFLAGS")?; let mut process = self.config.rustc()?.process(); process.arg("-") .arg("--crate-name").arg("___") @@ -613,17 +613,10 @@ impl<'a, 'cfg> Context<'a, 'cfg> { match self.get_package(id) { Ok(pkg) => { pkg.targets().iter().find(|t| t.is_lib()).map(|t| { - let profile = if unit.profile.check && - !t.is_custom_build() - && !t.for_host() { - &self.profiles.check - } else { - self.lib_profile() - }; let unit = Unit { pkg: pkg, target: t, - profile: profile, + profile: self.lib_or_check_profile(unit, t), kind: unit.kind.for_target(t), }; Ok(unit) @@ -780,7 +773,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { Unit { pkg: unit.pkg, target: t, - profile: self.lib_profile(), + profile: self.lib_or_check_profile(unit, t), kind: unit.kind.for_target(t), } }) @@ -848,6 +841,14 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } } + pub fn lib_or_check_profile(&self, unit: &Unit, target: &Target) -> &'a Profile { + if unit.profile.check && !target.is_custom_build() && !target.for_host() { + &self.profiles.check + } else { + self.lib_profile() + } + } + pub fn build_script_profile(&self, _pkg: &PackageId) -> &'a Profile { // TODO: should build scripts always be built with the same library // profile? How is this controlled at the CLI layer? -- 2.30.2